<template>
  <div class="box">
    <table-search
      slot="searchbar"
      v-model="searchData"
      :columns="searchOptions"
      @search="handleSearch"
    >
      <template slot="button">
        <a-button
          @click="handleExport"
          icon="download"
          style="color: #606266"
          slot="button"
          type="link"
        >
          导出
        </a-button>
        <!-- <a-button
          @click="handleAdd"
          icon="plus"
          style="color: #606266"
          slot="button"
          type="link"
        >
          添加
        </a-button> -->
      </template>
    </table-search>
    <div class="table-box">
      <a-table
        :columns="columns"
        :data-source="data"
        size="middle"
        :scroll="{ x: 1040 }"
        :pagination="false"
      >
        <template slot="index" slot-scope="scope">{{ scope.key }}</template>
        <!-- <template slot-scope="scope" slot="action">
          <a-button
            style="color: #2a5ee3"
            type="link"
            @click="handleEdit(scope)"
            size="small"
          >
            编辑
          </a-button>
          <a-button
            style="color: #f34f4a"
            type="link"
            @click="handleDelete(scope)"
            size="small"
          >
            删除
          </a-button>
        </template> -->
      </a-table>
      <div class="pagination-box">
        <a-pagination
          show-quick-jumper
          @change="handleChange"
          :show-total="(total) => `共 ${total} 条`"
          :defaultCurrent="pagination.current"
          :pageSize="pagination.pageSize"
          :total="pagination.total"
          :hideOnSinglePage="true"
        />
      </div>
    </div>
  </div>
</template>

<script>
import columns from "./colums";
export default {
  data() {
    return {
      columns,
      data: [
        {
          key: "1",
          supermarketName: "石庙陈东超市",
          taxpayer: "王萌萌",
          creditCode: "92371621MA3F123456789",
          legal: "王萌萌",
          phone: "13013021354",
          authorities: "石庙镇",
          area: "石庙镇",
          numCash: "6",
          address: "山东省滨州市啊啊啊啊啊啊啊啊啊啊",
        },
        {
          key: "2",
          supermarketName: "石庙陈东超市",
          taxpayer: "王萌萌",
          creditCode: "92371621MA3F123456789",
          legal: "王萌萌",
          phone: "13013021354",
          authorities: "石庙镇",
          area: "石庙镇",
          numCash: "6",
          address: "山东省滨州市啊啊啊啊啊啊啊啊啊啊",
        },
      ],
      pagination: {
        total: 50,
        current: 1,
        pageSize: 10,
      },
      searchData: {},
      searchOptions: [
        {
          type: "select",
          label: "所属超市",
          prop: "legal",
          attrs: {
            filterable: true,
          },
          enums: [
            {
              label: "石庙镇",
              value: "1",
            },
          ],
        },
        {
          type: "select",
          label: "收银机数量",
          prop: "taxation",
          attrs: {
            filterable: true,
          },
          enums: [
            {
              label: "石庙镇",
              value: "1",
            },
          ],
        },
      ],
    };
  },
  methods: {
    handleSearch(val) {
      console.log(val, "查询");
    },
    handleEdit(val) {
      console.log(val, "编辑");
    },
    handleDelete(val) {
      console.log(val, "删除");
    },
    handleChange(page, pageSize) {
      console.log(page, pageSize, "分页");
    },
    handleExport() {
      console.log("导出");
    },
    handleAdd() {
      console.log("添加");
    },
  },
};
</script>

<style lang="less" scoped>
.box {
  .table-box {
    padding-top: 30px;
  }
  .pagination-box {
    text-align: right;
    // position: absolute;
    // bottom: 40px;
    // right: 16px;
    padding-top: 40px;
    .ant-pagination {
      display: inline-block;
    }
  }
}
</style>
